package com.lanou.renrenxin.tools;

import com.lanou.renrenxin.R;

/**
 * Created by zouhui on 16/3/14.
 */
public class FileIconJudge {
    public static int judgeFileIcon(String fileName) {
        int index = fileName.lastIndexOf(".")+1;
        String suffix = "";
        if (index > 0) {
            suffix = fileName.substring(index,fileName.length());
        }

        int resId = 0;
        if ("log".equalsIgnoreCase(suffix) || "java".equalsIgnoreCase(suffix) || "txt".equalsIgnoreCase(suffix) || "text".equalsIgnoreCase(suffix) || "json".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_text;
        } else if ("doc".equalsIgnoreCase(suffix) || "docx".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_doc;
        } else if ("ppt".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_ppt;
        } else if ("xls".equalsIgnoreCase(suffix) | "xlsx".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_xls;
        } else if ("aac".equalsIgnoreCase(suffix) || "flac".equalsIgnoreCase(suffix) || "wav".equalsIgnoreCase(suffix) || "ape".equalsIgnoreCase(suffix) || "wma".equalsIgnoreCase(suffix) || "ogg".equalsIgnoreCase(suffix) || "mp3".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_music;
        } else if ("pdf".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_pdf;
        } else if ("html".equalsIgnoreCase(suffix) || "htm".equalsIgnoreCase(suffix) || "xml".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_html;
        } else if ("f4v".equalsIgnoreCase(suffix) || "3gp".equalsIgnoreCase(suffix) || "mkv".equalsIgnoreCase(suffix) || "wmv".equalsIgnoreCase(suffix) || "rm".equalsIgnoreCase(suffix) || "avi".equalsIgnoreCase(suffix) || "mp4".equalsIgnoreCase(suffix) || "rmvb".equalsIgnoreCase(suffix) || "flv".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_movie;
        } else if ("jpg".equalsIgnoreCase(suffix) || "jpeg".equalsIgnoreCase(suffix) || "png".equalsIgnoreCase(suffix) || "gif".equalsIgnoreCase(suffix) || "bmp".equalsIgnoreCase(suffix)) {
            resId = R.mipmap.ic_file_image;
        } else {
            resId = R.mipmap.ic_file_unknown;
        }
        return resId;
    }
}
